FUNCTION GEN_IBIS_MASK
; Generate IBIS Mask Pattern.

; Some Constants.
IBIS_MURA_ORD = 53
IBIS_MURA_ORG_SIZE = 107
IBIS_MURA_CUT_SIZE = 95 


;----------------------------------------------------
;-- JocobiQ will calculate the Jacobi value of (q,p).
;** Remember, this function is only suitable for IBIS
;** Mask which has MURA ORDER of 53.
;----------------------------------------------------
JacobiQ = [0,1,-1,-1,1,-1,1,1,-1,1,1,1,-1,1, $
           -1,1,1,1,-1,-1,-1,-1,-1,-1,1,1,-1,-1,1,1,-1,-1,-1, $
           -1,-1,-1,1,1,1,-1,1,-1,1,1,1,-1,1,1,-1,1,-1,-1,1]

; Initialize mura_org and mura_cut.
mura_org = intarr(IBIS_MURA_ORG_SIZE,IBIS_MURA_ORG_SIZE)
mura_cut = intarr(IBIS_MURA_CUT_SIZE,IBIS_MURA_CUT_SIZE)

; Initialize  horizon and vertical center lines.
mura_org[0:IBIS_MURA_ORG_SIZE-1,(IBIS_MURA_ORG_SIZE-1)/2-1]=0
mura_org[(IBIS_MURA_ORG_SIZE-1)/2-1,0:IBIS_MURA_ORG_SIZE-1]=1

mura_ord = intarr(IBIS_MURA_ORD, IBIS_MURA_ORD)
mura_ord = (JacobiQ#JacobiQ+1)/2
mura_ord[*,0] = 0
mura_ord[0,1:IBIS_MURA_ORD-1] = 1 

mura_cut[0:47,0:47]=ROTATE(mura_ord[0:47,0:47],2)
mura_cut[48:94,0:47]=ROTATE(mura_ord[1:47,0:47],7)
mura_cut[0:47,48:94]=ROTATE(mura_ord[0:47,1:47],5)
mura_cut[48:94,48:94]=mura_ord[1:47,1:47]

RETURN, mura_cut

END
